package ncme.auto.framework.core.entities.service;

import ncme.auto.framework.core.entities.aspect.autoParam.ResInAuto;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sjh
 * Description
 * create 2022/1/4 15:37
 */
public class SelectResult<E> {

    private List<E> pageData = new ArrayList<>();

    private Integer totalNum = 0;

    @Override
    public String toString() {
        return "searchResult{" +
                "pageData=" + pageData +
                ", totalNum=" + totalNum +
                '}';
    }

    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap();
        map.put("result", pageData);
        map.put("totalNum", totalNum);
        return map;
    }

    public ResInAuto toRes(){
        ResInAuto res = new ResInAuto(this.pageData);
        res.setResultNum(totalNum);
        return res;
    }

    public List<E> getPageData() {
        return pageData;
    }

    public void setPageData(List<E> pageData) {
        this.pageData = pageData;
    }

    public void addPageData(E data) {
        this.pageData.add(data);
    }

    public Integer getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(Integer totalNum) {
        this.totalNum = totalNum;
    }
}
